package task.manager;

import java.util.ArrayList;

/**
 * Task list that stores task objects.
 * 
 * @author Harrison Saylor, Aaron Mead, Marc Huet, Greg Ruskin
 * @version 2
 */
public class TaskList extends ArrayList<Task> {

	/**
	 * serial version UID
	 */
	private static final long serialVersionUID = 5L;
	
	/**
	 * Constructor. 
	 */
	public TaskList() {
		super();
	} // End of constructor.

	/**
	 * Returns true if the category exists, false otherwise.
	 * 
	 * @param i The location in the TaskList.
	 * @param activeCategory The category's name.
	 * @return True if the category exists, false otherwise.
	 */
	public boolean catNameEquals(int i, String activeCategory) {
		return this.get(i).catEquals(activeCategory);
	} // End of catNameEquals() method.
	
	/**
	 * Returns the particular task.
	 * 
	 * @param taskName Name of the task.
	 * @return The particular task, or null if it does not exist.
	 */
	public Task get(String taskName){
		Task retTask = null;
		for(int i = 0; i<size();i++){
			if(get(i).getTitle().equals(taskName)){
				retTask = get(i);
			} // End of if statement.
		} // End of for loop.
		return retTask;
	} // End of get() method.
	
	/**
	 * Deletes the particular task.
	 * 
	 * @param taskName Name of the task.
	 * @return The removed task, or null if nothing is removed.
	 */
	public Task delete(String taskName){
		for(int i = 0; i<size(); i++){
			if(this.get(i).getTitle().equals(taskName)){
				return this.remove(i);
			} // End of if statemen
		} // End of for loop.
		return null;
	} // End of delete() method.
	
} // End of TaskList class.
